package com.pig.controller;

import com.pig.entity.AccountLogEntity;
import com.pig.entity.AccountUserEntity;
import com.pig.entity.AccountUserInfoEntity;
import com.pig.entity.AfficheEntity;
import com.pig.pojo.AccounInfoPojo;
import com.pig.service.AccountInfoService;
import com.pig.service.AccountUserService;
import com.pig.service.AfficheService;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class AfficheController {


    /**
     * sercise
     */
    @Autowired
    private AfficheService afficheService;

    @Autowired
    private AccountInfoService accountInfoService;

    /**
     * 公告实体类
     */
    @Autowired
    private AfficheEntity afficheEntity;


    @RequestMapping("/affiche")
    @ResponseBody
    public Map<String, Object> queryAffiche(HttpServletRequest request, HttpSession session) {

        String accountName = (String) session.getAttribute("accountName");

        Map<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> list = afficheService.queryAffiche(map);

        for (Map<String, Object> stringObjectMap : list) {
            System.out.println(stringObjectMap);
        }
        map.put("accountName", accountName);
        AccounInfoPojo accounInfoPojo = new AccounInfoPojo();
        accounInfoPojo = accountInfoService.queryAccountInfo(map);
        String image = accounInfoPojo.getAccountInfoImage();
        System.out.println("image-- " + image);
        map.put("image", image);
        map.put("list", list);

        return map;
    }


}
